package com.zy.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * script switch_script if_script for_script while_script break_script
 *
 * @author : hanhuafeng
 * @date : 2023/11/13 17:26
 */
@Getter
public enum ScriptTypeEnum {
    /**
     * switch_script
     */
    SWITCH_SCRIPT("switch_script"),
    /**
     * if_script
     */
    IF_SCRIPT("if_script"),
    /**
     * for_script
     */
    FOR_SCRIPT("for_script"),
    /**
     * while_script
     */
    WHILE_SCRIPT("while_script"),
    /**
     * break_script
     */
    BREAK_SCRIPT("break_script");

    @EnumValue
    @JsonValue
    private final String type;

    ScriptTypeEnum(String type) {
        this.type = type;
    }


    @JsonCreator
    public static ScriptTypeEnum getEnum(String type) {
        for (ScriptTypeEnum scriptTypeEnum : ScriptTypeEnum.values()) {
            if (scriptTypeEnum.getType().equals(type)) {
                return scriptTypeEnum;
            }
        }
        return null;
    }
}
